#ifndef __PATH_H__
#define __PATH_H__

#include <vector>
#include <string>
#include <math.h>
#include "cNode.h"

//Going
#define STOP		0
#define CONTINUE	1
#define ARRIVE		2

#define STEP_LENGTH 0.3f

using namespace std;

struct sTrackPoint
{
	float x;
	float y;
};

class cPath
{
public:
	cPath(void);
	~cPath(void);

	int Init(vector< void* >* path);

	void Done();
	bool IsDone();

	void SetStepLength(float l);
	void SetSpeed(float s);
	int NextNode();
	int NextStep(int *x, int *y);

private:
	int status;
	cNode* currentNode;
	cNode* nextNode;
	vector< void* >* path;
	int nNodes;
	float t;
	int x;
	int y;
	float stepLenght;
	float speed;

	int i0,i1,i2,i3; // Indexes
	cNode *p0, *p1, *p2, *p3; // nodes

	void PointOnCurve(sTrackPoint& out, float t, sTrackPoint& p0, sTrackPoint& p1, sTrackPoint& p2, sTrackPoint& p3);
	void SetCurrentNodes();
	float Distance(cNode& n1, cNode& n2);
	float Cost(cNode& n1, cNode& n2);
};

#endif
